
//------------------------------------------------------------------------------
pulse.content.render = function( el, response )
{
	var resp = pulse.server.parseResponse( response.responseText );
	if ( resp.bExecuted )
		el.update( resp.sData );
	else
	{
		pulse.error( 'cannot update tab\'s content' );
		el.update( 'file error' );
	}
}

// ------------------------------------------------------------------------------
pulse.content.getFileIconClass = function(sFileName) {
	var parts = sFileName.split('.');
	if (parts.length <= 1)
		return 'iconFile';
	var sExtension = Ext.util.Format.lowercase(parts[parts.length - 1]);

	if (sExtension == 'xml') {
		if (parts.length > 2) {
			var sExtension2 = Ext.util.Format
					.lowercase(parts[parts.length - 2]);
			if (sExtension2 == 'char')
				return 'iconXmlChar';
			else if (sExtension2 == 'group')
				return 'iconXmlGroup';
			else if (sExtension2 == 'scene')
				return 'iconXmlScene';
			else
				return 'iconDoubleXml';
		} else
			return 'iconXml';
	} else if (sExtension == 'gif' || sExtension == 'jpeg'
			|| sExtension == 'jpg' || sExtension == 'png')
		return 'iconImage';
	else if (sExtension == 'pdf')
		return 'iconPdf';
	else
		return 'iconFile';
}

//------------------------------------------------------------------------------
pulse.content.loadFile = function( sFilePath )
{
  /*var bUnknownFileFormat = true;
  
  var parts = sFilePath.split('.');
  var firstExt = parts[ parts.length - 1 ];
  var bDoubleExtension = parts.length == 3;
  
  if ( bDoubleExtension && firstExt == 'xml' )
  {*/
    var oNewTab = pulse.tabPanel.add({
                    title: '<div class="loading-indicator">' + pulse.tabLoader.decorateTitle( sFilePath ) + '</div>',
                    iconCls: pulse.content.getFileIconClass( sFilePath ),
                    html: 'loading...',
                    closable:true
                  }).show();
                  
    oNewTab.body.getUpdater().setRenderer( pulse.content );
                  
    var tabData = new LoadingTabData( oNewTab.id, sFilePath );
    pulse.tabLoader.add( tabData );
                  
    oNewTab.load({
      url: pulse.server.getCommandUrl( 'load_file', 'file=' + sFilePath ),
      scope : tabData,
      callback: pulse.tabLoader.onDataCompleted,
      text: 'Loading...',
      timeout: 30,
      scripts: false
    });
    
    /*bUnknownFileFormat = false;
  }
  else if ( firstExt == 'jpg' || firstExt == 'jpeg' || firstExt == 'png' || firstExt == 'gif' )
  {
  }
  if ( bUnknownFileFormat )
    pulse.error( 'Unknown file format : ' + sFilePath );*/
};